#Copyright (c) 2025, Alibaba Cloud and its affiliates;
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at

#   http://www.apache.org/licenses/LICENSE-2.0

#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.



from sqlalchemy import create_engine, MetaData, inspect

# 创建数据库连接
engine = create_engine('sqlite:///sqlite.db')  # 替换为你的数据库文件名

# 创建 MetaData 对象
metadata = MetaData()

# 反向加载数据库中的表
metadata.reflect(bind=engine)

# 列出表名和列信息
for table_name in metadata.tables:
    print(f"Table: {table_name}")
    table = metadata.tables[table_name]
    for column in table.columns:
        print(f" - Column: {column.name}, Type: {column.type}")